package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("systematic/todo")
public @caption("待办事项") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("srv_todo") class SrvTodo implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("st_id")    @primary  @notnull  @note("  ") Long stId;// 主键 非空     
	private @caption("待办标题") @column("st_title") @like    @notnull  @note("  ") String stTitle;// 非空     
	private @caption("设定提醒时间") @column("st_alarm_time")      @note("  ") Date stAlarmTime;//     
	private @caption("所属人员") @column("st_user")     @notnull  @relate("$stUser") @RelateClass(SrvUser.class)  @note("  ") Long stUser;// 非空    /admin/permissions/user.query.do 
 	private transient SrvUser $stUser;//关联对象[人员信息]
	private @caption("待办内容") @column("st_content") @like     @note("  ") String stContent;//     
	private @caption("修改时间") @column("st_update_time")     @notnull  @note("  ") Date stUpdateTime;// 非空     
	private @caption("添加时间") @column("st_add_time")     @notnull  @note("  ") Date stAddTime;// 非空     
	private @caption("状态") @column("st_status")     @notnull  @note(" 0:待处理 1:提醒报警 2:已完成  ") Short stStatus;// 非空 0:待处理 1:提醒报警 2:已完成     
	 
	//默认构造函数
	public SrvTodo(){ 
	
	}
	
	//主键构造函数
	public SrvTodo(Long id){
		this.stId = id;
	}
	
	/**所有字段构造函数 
	 SrvTodo(
	 	Utils.getString("stTitle")//待办标题 [非空]
	 	,Utils.getDate("stAlarmTime")//设定提醒时间
	 	,Utils.getLong("stUser")//所属人员 [非空]
	 	,Utils.getString("stContent")//待办内容
	 	,Utils.getDate("stUpdateTime")//修改时间 [非空]
	 	,Utils.getDate("stAddTime")//添加时间 [非空]
	 	,Utils.getShort("stStatus")//状态 [非空]
	 )
	**/
	public SrvTodo(String stTitle,Date stAlarmTime,Long stUser,String stContent,Date stUpdateTime,Date stAddTime,Short stStatus){
		this.stTitle=stTitle;
		this.stAlarmTime=stAlarmTime;
		this.stUser=stUser;
		this.stContent=stContent;
		this.stUpdateTime=stUpdateTime;
		this.stAddTime=stAddTime;
		this.stStatus=stStatus;
	}
	
	//设置非空字段
	public SrvTodo setNotNull(String stTitle,Long stUser,Date stUpdateTime,Date stAddTime,Short stStatus){
		this.stTitle=stTitle;
		this.stUser=stUser;
		this.stUpdateTime=stUpdateTime;
		this.stAddTime=stAddTime;
		this.stStatus=stStatus;
		return this;
	}
	/** 编号 [非空]       **/
	public SrvTodo stId(Long stId){
		this.stId = stId;
		this.setSeted(F.stId);
		return this;
	}
	/** 待办标题 [非空]       **/
	public SrvTodo stTitle(String stTitle){
		this.stTitle = stTitle;
		this.setSeted(F.stTitle);
		return this;
	}
	/** 设定提醒时间        **/
	public SrvTodo stAlarmTime(Date stAlarmTime){
		this.stAlarmTime = stAlarmTime;
		this.setSeted(F.stAlarmTime);
		return this;
	}
	/** 所属人员 [非空] [SrvUser]     /admin/permissions/user.query.do **/
	public SrvTodo stUser(Long stUser){
		this.stUser = stUser;
		this.setSeted(F.stUser);
		return this;
	}
	/** 待办内容        **/
	public SrvTodo stContent(String stContent){
		this.stContent = stContent;
		this.setSeted(F.stContent);
		return this;
	}
	/** 修改时间 [非空]       **/
	public SrvTodo stUpdateTime(Date stUpdateTime){
		this.stUpdateTime = stUpdateTime;
		this.setSeted(F.stUpdateTime);
		return this;
	}
	/** 添加时间 [非空]       **/
	public SrvTodo stAddTime(Date stAddTime){
		this.stAddTime = stAddTime;
		this.setSeted(F.stAddTime);
		return this;
	}
	/** 状态 [非空]   0:待处理 1:提醒报警 2:已完成     **/
	public SrvTodo stStatus(Short stStatus){
		this.stStatus = stStatus;
		this.setSeted(F.stStatus);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public SrvTodo clone(){
		SrvTodo clone = new SrvTodo();
		clone.stTitle=this.stTitle;
		clone.stAlarmTime=this.stAlarmTime;
		clone.stUser=this.stUser;
		clone.stContent=this.stContent;
		clone.stUpdateTime=this.stUpdateTime;
		clone.stAddTime=this.stAddTime;
		clone.stStatus=this.stStatus;
		return clone;
	}
	
	
	/**
	 * 根据ID取待办事项
	 * @param id
	 * @return
	 */
	public static @api SrvTodo get(Long id){		
		return getSrvTodoById(id);
	}
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.stId = id;
	}
	
	/**
	 * 获取所有待办事项
	 * @return
	 */
	public static @api List<SrvTodo> list(Map params,Integer size){
		return getSrvTodoList(params,size);
	}
	/**
	 * 获取待办事项分页
	 * @return
	 */
	public static @api Page<SrvTodo> page(Integer page,Integer size,Map params){
		return getSrvTodoPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取待办事项
	 * @param params
	 * @return
	 */
	public static @api SrvTodo Get(Map params){
		return getSrvTodo(params);
	}
	/**
	 * 获取待办事项数
	 * @return
	 */
	public static @api Long count(Map params){
		return getSrvTodoCount(params);
	}
	/**
	 * 获取待办事项数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getSrvTodoEval(eval,params);
	}
	/**
	 * 获取待办事项图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getSrvTodoStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取待办事项图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getSrvTodoStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取待办事项
	 * @param id
	 * @return
	 */
	public static @api SrvTodo getSrvTodoById(Long id){		
		return getSrvTodoDao().getSrvTodoById(id);
	}
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.stId;
	}
	
	
	/**
	 * 根据ID取待办事项的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		value = Cache.getValue(SrvTodo.class, id);
		if(value==null){
			SrvTodo srvTodo = get(id);
			if(srvTodo!=null){
				String strValue = srvTodo.getStTitle$();
				if(!"StTitle".equals("StTitle"))
					strValue+="("+srvTodo.getStTitle$()+")";
				Cache.setValue(SrvTodo.class, id ,strValue);
				value = strValue;
			}else{
				Cache.setValue(SrvTodo.class, id ,"{"+id+"}",30);
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getStTitle$();
		if(!"StTitle".equals("StTitle"))
			keyValue+="("+this.getStTitle$()+")";
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询待办事项对象
	 * @return
	 */
	public static @api SrvTodo find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("stId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex+=" or st_title = '"+key.replaceAll("'", "''")+"'";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return SrvTodo.getSrvTodo(params);
	}
	
	
	/**
	 * 根据关键字查询待办事项
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","st_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("stId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex+=" or st_title like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<SrvTodo> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(SrvTodo srvTodo:list){
			Map map = new HashMap();
			map.put("key",srvTodo.getStId().toString());
			map.put("value", Utils.js(srvTodo.getKeyValue()));
			if(bObject==true)
				map.put("object",srvTodo);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有待办事项
	 * @return
	 */
	public static @api List<SrvTodo> getSrvTodoList(Map params,Integer size){
		return getSrvTodoDao().getSrvTodoList(params,0,size);
	}
	
	/**
	 * 获取待办事项分页
	 * @return
	 */
	public static @api Page<SrvTodo> getSrvTodoPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getSrvTodoDao().getSrvTodoPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取待办事项
	 * @param params
	 * @return
	 */
	public static @api SrvTodo getSrvTodo(Map params){
		return getSrvTodoDao().getSrvTodo(params);
	}
	
	/**
	 * 保存一个待办事项
	 * @param srvTodo
	 * @return
	 */
	public static @api SrvTodo saveSrvTodo(SrvTodo srvTodo){
		return getSrvTodoDao().saveSrvTodo(srvTodo);
	}
	
	/**
	 * 根据条件更新待办事项
	 * @param values
	 * @param params
	 */
	public static @api int updateSrvTodoByConfirm(Map values, Map params){
		return getSrvTodoDao().updateSrvTodoByConfirm(values,params);
	}
	
	/**
	 * 修改一个待办事项
	 * @param srvTodo
	 * @return
	 */
	public static @api int updateSrvTodo(SrvTodo srvTodo){
		return getSrvTodoDao().updateSrvTodo(srvTodo);
	}
	
	/**
	 * 更新待办事项非空字段
	 * @param srvTodo
	 */
	public static @api int updateSrvTodo$NotNull(SrvTodo srvTodo){
		return getSrvTodoDao().updateSrvTodo$NotNull(srvTodo);
	}
	
	/**
	 * 获取待办事项数
	 * @return
	 */
	public static @api Long getSrvTodoCount(Map params){
		return getSrvTodoDao().getSrvTodoCount(params);
	}
		
		
	/**
	 * 获取待办事项自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getSrvTodoEval(String eval,Map params){
		return getSrvTodoDao().getSrvTodoEval(eval,params);
	}
	/**
	 * 获取待办事项图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getSrvTodoStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getSrvTodoDao().getSrvTodoStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = SrvTodo.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(SrvTodo.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateSrvTodo(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getSrvTodoDao().updateSrvTodoByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteSrvTodo(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getSrvTodoDao().deleteSrvTodoByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getSrvTodoDao().removeSrvTodoById(id);
	}
	
	
	/**
	 * 保存待办事项对象
	 * @param params
	 * @return
	 */
	public SrvTodo save(){
		if(this.getStId()!=null)
			getSrvTodoDao().updateSrvTodo(this);
		else
			return getSrvTodoDao().saveSrvTodo(this);
		return this;
	}
	
	
	/**
	 * 更新待办事项对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getSrvTodoDao().updateSrvTodo$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getSrvTodoDao().removeSrvTodoById(this.getStId());
		else
			getSrvTodoDao().deleteSrvTodoById(this.getStId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getSrvTodoDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getStId(){
		if(this.stId!=null){
			return this.stId;
		}
		return this.stId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getStId$(){
		String strValue="";
		 strValue=Utils.string(this.getStId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setStId$(String strValue){
		if(Utils.empty(strValue)){
			this.stId=null;
			return;
		}
	 	this.stId=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setStId(Long stId){
		this.stId = stId;
		this.setSeted(F.stId);
	}
	
	
	
	
	/*******************************待办标题**********************************/	
	/**
	* 待办标题 [非空]      
	**/
	public String getStTitle(){
		if(this.stTitle!=null){
			return this.stTitle;
		}
		return this.stTitle;
	}
	/**
	* 获取待办标题格式化(toString)
	**/
	public String getStTitle$(){
		String strValue="";
		 strValue=Utils.string(this.getStTitle());
	 	 return strValue;
	}
	/**
	* 根据待办标题反格式化
	**/
	public void setStTitle$(String strValue){
		if(Utils.empty(strValue)){
			this.stTitle=null;
			return;
		}
	 	this.stTitle=strValue;
	}
	
	/**
	* 待办标题 [非空]      
	**/
	public void setStTitle(String stTitle){
		this.stTitle = stTitle;
		this.setSeted(F.stTitle);
	}
	
	
	
	
	/*******************************设定提醒时间**********************************/	
	/**
	* 设定提醒时间       
	**/
	public Date getStAlarmTime(){
		if(this.stAlarmTime!=null){
			return this.stAlarmTime;
		}
		return this.stAlarmTime;
	}
	/**
	* 获取设定提醒时间格式化(toString)
	**/
	public String getStAlarmTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getStAlarmTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据设定提醒时间反格式化
	**/
	public void setStAlarmTime$(String strValue){
		if(Utils.empty(strValue)){
			this.stAlarmTime=null;
			return;
		}
	 	this.stAlarmTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 设定提醒时间       
	**/
	public void setStAlarmTime(Date stAlarmTime){
		this.stAlarmTime = stAlarmTime;
		this.setSeted(F.stAlarmTime);
	}
	
	
	
	
	/*******************************所属人员**********************************/	
	/**
	* 所属人员 [非空] [SrvUser]     /admin/permissions/user.query.do
	**/
	public Long getStUser(){
		if(this.stUser!=null){
			return this.stUser;
		}
		return this.stUser;
	}
	/**
	* 获取所属人员格式化(toString)
	**/
	public String getStUser$(){
		String strValue="";
		if(this.getStUser()!=null){
				strValue+=Utils.string(SrvUser.getKeyValue(this.getStUser()));
		}			
	 	 return strValue;
	}
	/**
	* 根据所属人员反格式化
	**/
	public void setStUser$(String strValue){
		if(Utils.empty(strValue)){
			this.stUser=null;
			return;
		}
		SrvUser item = SrvUser.find(strValue);
		if(item!=null){
			this.stUser = Utils.parseLong(item.getSuId());
		}
	}
	
	/**
	* 所属人员 [非空] [SrvUser]     /admin/permissions/user.query.do
	**/
	public void setStUser(Long stUser){
		this.stUser = stUser;
		this.setSeted(F.stUser);
	}
	
	
	
	
	/**
	* 获取关联对象[人员信息]
	**/	 			
 	public SrvUser get$stUser(){
 		if(this.$stUser!=null)
 			return this.$stUser;
 		com.distribute.framework.model.SrvUser srvUser = null;
		if(this.getStUser()!=null){
 			srvUser = SrvUser.get(this.getStUser());
 		}
 		return srvUser;
	}
	/*******************************待办内容**********************************/	
	/**
	* 待办内容       
	**/
	public String getStContent(){
		if(this.stContent!=null){
			return this.stContent;
		}
		return this.stContent;
	}
	/**
	* 获取待办内容格式化(toString)
	**/
	public String getStContent$(){
		String strValue="";
		 strValue=Utils.string(this.getStContent());
	 	 return strValue;
	}
	/**
	* 根据待办内容反格式化
	**/
	public void setStContent$(String strValue){
		if(Utils.empty(strValue)){
			this.stContent=null;
			return;
		}
		this.stContent=strValue;
	}
	
	/**
	* 待办内容       
	**/
	public void setStContent(String stContent){
		this.stContent = stContent;
		this.setSeted(F.stContent);
	}
	
	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getStUpdateTime(){
		if(this.stUpdateTime!=null){
			return this.stUpdateTime;
		}
		return this.stUpdateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getStUpdateTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getStUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setStUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.stUpdateTime=null;
			return;
		}
	 	this.stUpdateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setStUpdateTime(Date stUpdateTime){
		this.stUpdateTime = stUpdateTime;
		this.setSeted(F.stUpdateTime);
	}
	
	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getStAddTime(){
		if(this.stAddTime!=null){
			return this.stAddTime;
		}
		return this.stAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getStAddTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getStAddTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setStAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.stAddTime=null;
			return;
		}
	 	this.stAddTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setStAddTime(Date stAddTime){
		this.stAddTime = stAddTime;
		this.setSeted(F.stAddTime);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   0:待处理 1:提醒报警 2:已完成    
	**/
	public Short getStStatus(){
		if(this.stStatus!=null){
			return this.stStatus;
		}
		return this.stStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getStStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getStStatus()),"0"))
			strValue=Utils.string("待处理");		 
		 if(Utils.equals(Utils.string(this.getStStatus()),"1"))
			strValue=Utils.string("提醒报警");		 
		 if(Utils.equals(Utils.string(this.getStStatus()),"2"))
			strValue=Utils.string("已完成");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setStStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.stStatus=null;
			return;
		}
		 if(Utils.equals(strValue,"待处理"))
		 	this.stStatus=Utils.parseShort("0");
		 if(Utils.equals(strValue,"提醒报警"))
		 	this.stStatus=Utils.parseShort("1");
		 if(Utils.equals(strValue,"已完成"))
		 	this.stStatus=Utils.parseShort("2");
	}
	
	/**
	* 状态 [非空]   0:待处理 1:提醒报警 2:已完成    
	**/
	public void setStStatus(Short stStatus){
		this.stStatus = stStatus;
		this.setSeted(F.stStatus);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(SrvTodo.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(SrvTodo.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(SrvTodo.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(SrvTodo.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(SrvTodo.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${SrvTodo.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvTodo.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvTodo.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(SrvTodo.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${SrvTodo.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvTodo.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvTodo.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(SrvTodo.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M stId(Object stId){if(proxy)return proxy().stId(stId);  this.put("stId", stId);return this;};
	 	/** and st_id is null */
 		public M stIdNull(){if(proxy)return proxy().stIdNull();if(this.get("stIdNot")==null)this.put("stIdNot", "");this.put("stId", null);return this;};
 		/** not .... */
 		public M stIdNot(){if(proxy)return proxy().stIdNot();this.put("stIdNot", "not");return this;};
 		public M stIdNotNull(){if(proxy)return proxy().stIdNotNull();this.put("stIdNot", "not");this.put("stId", null);return this;};
 		public M stIdNot(Object stId){if(proxy)return proxy().stIdNot(stId);this.put("stIdNot", "not");this.put("stId", stId);return this;};
		/** and st_id <= ? */
		public M stIdMin(Object min){if(proxy)return proxy().stIdMin(min);this.put("stIdMin", min);return this;};
		/** and st_id >= ? */
		public M stIdMax(Object max){if(proxy)return proxy().stIdMax(max);this.put("stIdMax", max);return this;};
		public M stIdIn(String ids){
			if(proxy)return proxy().stIdIn(ids);  this.put("stIdIn", ids);return this;
		};	
		/** 待办标题 [非空]       **/
		public M stTitle(Object stTitle){if(proxy)return proxy().stTitle(stTitle);  this.put("stTitle", stTitle);return this;};
	 	/** and st_title is null */
 		public M stTitleNull(){if(proxy)return proxy().stTitleNull();if(this.get("stTitleNot")==null)this.put("stTitleNot", "");this.put("stTitle", null);return this;};
 		/** not .... */
 		public M stTitleNot(){if(proxy)return proxy().stTitleNot();this.put("stTitleNot", "not");return this;};
 		public M stTitleNotNull(){if(proxy)return proxy().stTitleNotNull();this.put("stTitleNot", "not");this.put("stTitle", null);return this;};
 		public M stTitleNot(Object stTitle){if(proxy)return proxy().stTitleNot(stTitle);this.put("stTitleNot", "not");this.put("stTitle", stTitle);return this;};
		/** 设定提醒时间        **/
		public M stAlarmTime(Object stAlarmTime){if(proxy)return proxy().stAlarmTime(stAlarmTime);  this.put("stAlarmTime", stAlarmTime);return this;};
	 	/** and st_alarm_time is null */
 		public M stAlarmTimeNull(){if(proxy)return proxy().stAlarmTimeNull();if(this.get("stAlarmTimeNot")==null)this.put("stAlarmTimeNot", "");this.put("stAlarmTime", null);return this;};
 		/** not .... */
 		public M stAlarmTimeNot(){if(proxy)return proxy().stAlarmTimeNot();this.put("stAlarmTimeNot", "not");return this;};
 		public M stAlarmTimeNotNull(){if(proxy)return proxy().stAlarmTimeNotNull();this.put("stAlarmTimeNot", "not");this.put("stAlarmTime", null);return this;};
 		public M stAlarmTimeNot(Object stAlarmTime){if(proxy)return proxy().stAlarmTimeNot(stAlarmTime);this.put("stAlarmTimeNot", "not");this.put("stAlarmTime", stAlarmTime);return this;};
 		/** and st_alarm_time >= ? */
 		public M stAlarmTimeStart(Object start){if(proxy)return proxy().stAlarmTimeStart(start);this.put("stAlarmTimeStart", start);return this;};			
 		/** and st_alarm_time <= ? */
 		public M stAlarmTimeEnd(Object end){if(proxy)return proxy().stAlarmTimeEnd(end);this.put("stAlarmTimeEnd", end);return this;};
		public M stUser$on(SrvUser.M value){if(proxy)return proxy().stUser$on(value);this.put("StUser", value);value.put("on", "st_user");return this;};
		/** 所属人员 [非空] [SrvUser]     /admin/permissions/user.query.do **/
		public M stUser(Object stUser){if(proxy)return proxy().stUser(stUser);  this.put("stUser", stUser);return this;};
	 	/** and st_user is null */
 		public M stUserNull(){if(proxy)return proxy().stUserNull();if(this.get("stUserNot")==null)this.put("stUserNot", "");this.put("stUser", null);return this;};
 		/** not .... */
 		public M stUserNot(){if(proxy)return proxy().stUserNot();this.put("stUserNot", "not");return this;};
 		public M stUserNotNull(){if(proxy)return proxy().stUserNotNull();this.put("stUserNot", "not");this.put("stUser", null);return this;};
 		public M stUserNot(Object stUser){if(proxy)return proxy().stUserNot(stUser);this.put("stUserNot", "not");this.put("stUser", stUser);return this;};
		public M stUserIn(String ids){
			if(proxy)return proxy().stUserIn(ids);  this.put("stUserIn", ids);return this;
		};	
		/** 待办内容        **/
		public M stContent(Object stContent){if(proxy)return proxy().stContent(stContent);  this.put("stContent", stContent);return this;};
	 	/** and st_content is null */
 		public M stContentNull(){if(proxy)return proxy().stContentNull();if(this.get("stContentNot")==null)this.put("stContentNot", "");this.put("stContent", null);return this;};
 		/** not .... */
 		public M stContentNot(){if(proxy)return proxy().stContentNot();this.put("stContentNot", "not");return this;};
 		public M stContentNotNull(){if(proxy)return proxy().stContentNotNull();this.put("stContentNot", "not");this.put("stContent", null);return this;};
 		public M stContentNot(Object stContent){if(proxy)return proxy().stContentNot(stContent);this.put("stContentNot", "not");this.put("stContent", stContent);return this;};
		/** 修改时间 [非空]       **/
		public M stUpdateTime(Object stUpdateTime){if(proxy)return proxy().stUpdateTime(stUpdateTime);  this.put("stUpdateTime", stUpdateTime);return this;};
	 	/** and st_update_time is null */
 		public M stUpdateTimeNull(){if(proxy)return proxy().stUpdateTimeNull();if(this.get("stUpdateTimeNot")==null)this.put("stUpdateTimeNot", "");this.put("stUpdateTime", null);return this;};
 		/** not .... */
 		public M stUpdateTimeNot(){if(proxy)return proxy().stUpdateTimeNot();this.put("stUpdateTimeNot", "not");return this;};
 		public M stUpdateTimeNotNull(){if(proxy)return proxy().stUpdateTimeNotNull();this.put("stUpdateTimeNot", "not");this.put("stUpdateTime", null);return this;};
 		public M stUpdateTimeNot(Object stUpdateTime){if(proxy)return proxy().stUpdateTimeNot(stUpdateTime);this.put("stUpdateTimeNot", "not");this.put("stUpdateTime", stUpdateTime);return this;};
 		/** and st_update_time >= ? */
 		public M stUpdateTimeStart(Object start){if(proxy)return proxy().stUpdateTimeStart(start);this.put("stUpdateTimeStart", start);return this;};			
 		/** and st_update_time <= ? */
 		public M stUpdateTimeEnd(Object end){if(proxy)return proxy().stUpdateTimeEnd(end);this.put("stUpdateTimeEnd", end);return this;};
		/** 添加时间 [非空]       **/
		public M stAddTime(Object stAddTime){if(proxy)return proxy().stAddTime(stAddTime);  this.put("stAddTime", stAddTime);return this;};
	 	/** and st_add_time is null */
 		public M stAddTimeNull(){if(proxy)return proxy().stAddTimeNull();if(this.get("stAddTimeNot")==null)this.put("stAddTimeNot", "");this.put("stAddTime", null);return this;};
 		/** not .... */
 		public M stAddTimeNot(){if(proxy)return proxy().stAddTimeNot();this.put("stAddTimeNot", "not");return this;};
 		public M stAddTimeNotNull(){if(proxy)return proxy().stAddTimeNotNull();this.put("stAddTimeNot", "not");this.put("stAddTime", null);return this;};
 		public M stAddTimeNot(Object stAddTime){if(proxy)return proxy().stAddTimeNot(stAddTime);this.put("stAddTimeNot", "not");this.put("stAddTime", stAddTime);return this;};
 		/** and st_add_time >= ? */
 		public M stAddTimeStart(Object start){if(proxy)return proxy().stAddTimeStart(start);this.put("stAddTimeStart", start);return this;};			
 		/** and st_add_time <= ? */
 		public M stAddTimeEnd(Object end){if(proxy)return proxy().stAddTimeEnd(end);this.put("stAddTimeEnd", end);return this;};
		/** 状态 [非空]   0:待处理 1:提醒报警 2:已完成     **/
		public M stStatus(Object stStatus){if(proxy)return proxy().stStatus(stStatus);  this.put("stStatus", stStatus);return this;};
	 	/** and st_status is null */
 		public M stStatusNull(){if(proxy)return proxy().stStatusNull();if(this.get("stStatusNot")==null)this.put("stStatusNot", "");this.put("stStatus", null);return this;};
 		/** not .... */
 		public M stStatusNot(){if(proxy)return proxy().stStatusNot();this.put("stStatusNot", "not");return this;};
 		public M stStatusNotNull(){if(proxy)return proxy().stStatusNotNull();this.put("stStatusNot", "not");this.put("stStatus", null);return this;};
 		public M stStatusNot(Object stStatus){if(proxy)return proxy().stStatusNot(stStatus);this.put("stStatusNot", "not");this.put("stStatus", stStatus);return this;};
		public M stStatusIn(String ids){
			if(proxy)return proxy().stStatusIn(ids);  this.put("stStatusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有待办事项 **/
		public @api List<SrvTodo> list(Integer size){			
			return getSrvTodoList(this,size);
		}
		/** 获取待办事项分页 **/
		public @api Page<SrvTodo> page(Integer page,Integer size){			
			return getSrvTodoPage(page, size , this);
		}
		/** 根据查询条件取待办事项 **/
		public @api SrvTodo get(){			
			return getSrvTodo(this);
		}
		/** 获取待办事项数 **/
		public @api Long count(){			
			return getSrvTodoCount(this);
		}
		/** 获取待办事项表达式 **/
		public @api <T> T eval(String strEval){			
			return getSrvTodoEval(strEval,this);
		}
		/** 获取待办事项统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getSrvTodoStats(this,sumKey,groupKey,dateType);
		}
		/** 获取待办事项统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getSrvTodoStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateSrvTodo(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteSrvTodo(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String stId="stId";
		/** 待办标题 [非空]       **/
		public final static @type(String.class) @like String stTitle="stTitle";
		/** 设定提醒时间        **/
		public final static @type(Date.class)  String stAlarmTime="stAlarmTime";
	 	/** and st_alarm_time >= ? */
 		public final static @type(Date.class) String stAlarmTimeStart="stAlarmTimeStart";
 		/** and st_alarm_time <= ? */
 		public final static @type(Date.class) String stAlarmTimeEnd="stAlarmTimeEnd";
		/** 所属人员 [非空] [SrvUser]     /admin/permissions/user.query.do **/
		public final static @type(Long.class)  String stUser="stUser";
		/** 待办内容        **/
		public final static @type(String.class) @like String stContent="stContent";
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String stUpdateTime="stUpdateTime";
	 	/** and st_update_time >= ? */
 		public final static @type(Date.class) String stUpdateTimeStart="stUpdateTimeStart";
 		/** and st_update_time <= ? */
 		public final static @type(Date.class) String stUpdateTimeEnd="stUpdateTimeEnd";
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String stAddTime="stAddTime";
	 	/** and st_add_time >= ? */
 		public final static @type(Date.class) String stAddTimeStart="stAddTimeStart";
 		/** and st_add_time <= ? */
 		public final static @type(Date.class) String stAddTimeEnd="stAddTimeEnd";
		/** 状态 [非空]   0:待处理 1:提醒报警 2:已完成     **/
		public final static @type(Short.class)  String stStatus="stStatus";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		stId("st_id"),
		stTitle("st_title"),
		stAlarmTime("st_alarm_time"),
		stUser("st_user"),
		stContent("st_content"),
		stUpdateTime("st_update_time"),
		stAddTime("st_add_time"),
		stStatus("st_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取待办事项数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = SrvTodo.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = SrvTodo.getSrvTodo(params);
			else
				value = SrvTodo.getSrvTodoList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  SrvTodo.where().stId(param).get();
		else if(!Utils.empty(param.toString()))
			value = SrvTodo.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getStId());
		Utils.fms(map,simple?"id":"stId",this.getStId(),this.getStId$());
		Utils.fms(map,simple?"title":"stTitle",this.getStTitle(),this.getStTitle$());
		Utils.fms(map,simple?"alarmTime":"stAlarmTime",this.getStAlarmTime(),this.getStAlarmTime$());
		Utils.fms(map,simple?"user":"stUser",this.getStUser(),this.getStUser$());
		Utils.fms(map,simple?"content":"stContent",this.getStContent(),this.getStContent$());
		Utils.fms(map,simple?"updateTime":"stUpdateTime",this.getStUpdateTime(),this.getStUpdateTime$());
		Utils.fms(map,simple?"addTime":"stAddTime",this.getStAddTime(),this.getStAddTime$());
		Utils.fms(map,simple?"status":"stStatus",this.getStStatus(),this.getStStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("stId",this.getStId());
		map.put("stTitle",this.getStTitle());
		map.put("stAlarmTime",this.getStAlarmTime());
		map.put("stUser",this.getStUser());
		map.put("stContent",this.getStContent());
		map.put("stUpdateTime",this.getStUpdateTime());
		map.put("stAddTime",this.getStAddTime());
		map.put("stStatus",this.getStStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static SrvTodo fromMap(Map map){
		SrvTodo srvTodo = new SrvTodo();
		srvTodo.stId = Utils.parseLong(map.get("stId"));
		srvTodo.stTitle = Utils.parseString(map.get("stTitle"));
		srvTodo.stAlarmTime = Utils.parseDate(map.get("stAlarmTime"));
		srvTodo.stUser = Utils.parseLong(map.get("stUser"));
		srvTodo.stContent = Utils.parseString(map.get("stContent"));
		srvTodo.stUpdateTime = Utils.parseDate(map.get("stUpdateTime"));
		srvTodo.stAddTime = Utils.parseDate(map.get("stAddTime"));
		srvTodo.stStatus = Utils.parseShort(map.get("stStatus"));
		return srvTodo;
	}
	
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(SrvTodo old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/200882564225077801.png";
	}
	public static String getIconfont(){
		return "icon-naozhong-copy";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,SrvTodo.M params){
		if(params==null)params=new SrvTodo.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/systematic/todo.edit.html?";
		if(params.get("stId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("stId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/systematic/todo.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.stId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(SrvTodo.ACT act,SrvTodo.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",SrvTodo.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(SrvTodo.ACT act,SrvTodo.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",SrvTodo.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ISrvTodoDao getSrvTodoDao(){
		return Utils.getBean("srvTodoDao");
	};
	
}